package com.mima.minaserver.repository;

import java.util.Date;
import javax.transaction.Transactional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.mima.minaserver.entity.HeartBeatEntity;

@Repository
public interface HeardBeatRepository extends JpaRepository<HeartBeatEntity, Object> {
	
	@Modifying
	@Transactional
	@Query(value = "insert into t_heartbeat(uuid,username,password,heartp_time) values(?,?,?,?)", nativeQuery = true)
	public void insertHeadBeat(String uuid,String username,String password,Date hearpt_time);
	
	@Modifying
	@Transactional
	@Query(value = "update t_heartbeat set key_id = ?5, heartp_time = ?4,username = ?2,password = ?3 where uuid= ?1", nativeQuery = true)
	public void updateHeadBeat(String uuid,String username,String password,Date hearpt_time,Integer key_id );
	
	@Query(value = "select * from t_heartbeat where uuid= ?1", nativeQuery = true)
	public HeartBeatEntity fetchHeadBeat(String uuid);
}
